
<html xmlns="http://www.w3.org/1999/xhtml">

<!--

   Copyright 2007 Nico Goeminne (nicogoeminne@gmail.com)



   Licensed under the Apache License, Version 2.0 (the "License");

   you may not use this file except in compliance with the License.

   You may obtain a copy of the License at



       http://www.apache.org/licenses/LICENSE-2.0



   Unless required by applicable law or agreed to in writing, software

   distributed under the License is distributed on an "AS IS" BASIS,

   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

   See the License for the specific language governing permissions and

   limitations under the License.

-->

  <head>

    <title>GReverseGeocoder v1.0.5 Example</title>

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAsDELmuOSQh2x6rOkeMR1FRTinQmAoIpAbE0OY077NMR3enrO0RQneZQr3gCDD_OB-ki66PwOomxhzg"></script>

<script src="/spymenow_web/js/greversegeocoderv105.js" type="text/javascript"></script>


    <script type="text/javascript">



// GMap2 object

var map;

// GReverseGeocoder object

var rg;

// text input fields

var lat;

var lng;

// result div

var info;



function load() {

  if (GBrowserIsCompatible()) {

    lat = document.getElementById("lat");

    lng = document.getElementById("lng");

    info = document.getElementById("info");



    map = new GMap2(document.getElementById("map"));

    map.setCenter(new GLatLng(51.05226693177032, 3.723893165588379), 15);

    map.addControl(new GLargeMapControl());

    rg = new GReverseGeocoder(map);



    // add listners for the results

    GEvent.addListener(rg, "load", goodresult);

    GEvent.addListener(rg, "error", badresult);

    // Clicking on the map fills in the lat and lng fields

    // Just handy

    GEvent.addListener(map, "click", handleClicks);

  }

}



// is called with a placemark if the reverse geocode request was successfull

// sets the result div

function goodresult(placemark) {

  var html = placemark.address + '<br />' + '<b>Country code:</b> ' + placemark.AddressDetails.Country.CountryNameCode;

  info.innerHTML = html;

  var postalcodenumber = rg.getPlacemarkProperty(placemark,"PostalCodeNumber");

  if (postalcodenumber != null) alert("Postal Code Number: " + postalcodenumber);

  else alert("Postal Code Number Unknown");

}



// is called if the reverse geocode request was unsuccessfull

function badresult() {

  info.innerHTML = "Unable to reverse geocode";

}



// get the input form lat and lng fields and issue a reverse geocode

// request

function reverse(){

  var point = new GLatLng(lat.value,lng.value);

  rg.reverseGeocode(point);

}



// handy method to fill in the lat and lng fields by clicking on the map.

function handleClicks(marker, point){

  lat.value=point.lat();

  lng.value=point.lng();

}

  </script>



</head>



<body onload="load()" onunload="GUnload()">

  <p>Reverse Geocoding Example using the GReverseGeocder v1.0.5<br />

  The example below uses the getPlacemarkProperty function to get the "PostalCode"<br />

Copyright 2007, Nico Goeminne<br />

nicogoeminne at gmail.com</p>

<table>

<tr><td>Latitude (WGS84)</td><td><input id="lat" type="text" size="20" value="" /></td></tr>

<tr><td>Longitude (WGS84)</td><td><input id="lng" type="text" size="20" value="" /></td></tr>

<tr><td><input type="button" onclick="reverse()" value="Get Address"></td><td><div id="info"></div></td></tr>

<tr><td colspan="2"><div id="map" style="width: 400px; height: 400px;"></div></td></tr>

</table>

<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>

<script type="text/javascript">

var pageTracker = _gat._getTracker("UA-6612551-1");

//pageTracker._setDomainName("zeali.net");

pageTracker._initData();

pageTracker._trackPageview();

</script>

</body></html>